import fileValidation as fv
import global_objects as go
import string as s

#del fv.tables[0:]
#fv.split_methadata('F:/Magistratura/Software Techologies/2nd_semester2009-2010/ST2/project/Pexample.txt')
#print fv.tables

#tblsCnt = len(fv.tables)
def getTables():
    tblsCnt = len(fv.tables)
    del go.tbls[0:]
    for i in range(0,tblsCnt):
        go.tbls.append([fv.tables[i][0].split('(')[0].strip(),int(fv.tables[i][0].split(',')[1].split(')')[0].strip())])
       
def getColumns():
    tblsCnt = len(fv.tables)
    del go.clmns[0:]
    for i in range(0,tblsCnt):
        clmnCnt = len(fv.tables[i])
        for j in range(1,clmnCnt):
            if j==1 and clmnCnt>0:
                go.clmns.append([fv.tables[i][j].split(':')[0].strip()])
            else:
                go.clmns[i].append(fv.tables[i][j].split(':')[0].strip())            

def getTypes():
    tblsCnt = len(fv.tables)
    del go.types[0:]
    for i in range(0,tblsCnt):
        typCnt = len(fv.tables[i])
        for j in range(1,typCnt):
            if j==1 and typCnt>0:
                go.types.append([fv.tables[i][j].split(':')[1].split('(')[0].strip()])
            else:
                go.types[i].append(fv.tables[i][j].split(':')[1].split('(')[0].strip())            

def getArgs():
    tblsCnt = len(fv.tables)
    del go.args[0:]
    for i in range(0,tblsCnt):
        colCnt = len(fv.tables[i])

        for j in range(1,colCnt):
            if len (fv.tables[i][j].split('('))==1:
                    if j==1:
                        go.args.append([[]])
                    else:
                        go.args[i].append([])
            else:
                if j==1:
                    go.args.append([map(s.strip, fv.tables[i][j].split('(')[1].split(')')[0].split(','))])
                    #print go.args
                else:
                    go.args[i].append(map(s.strip, fv.tables[i][j].split('(')[1].split(')')[0].split(',')))
                   
                #print a    
               # go.args[i].append()
                #print go.args
#getArgs()
#print go.args

